/*	Copyright 2007 - Xavier Baro (xbaro@cvc.uab.cat)

	This file is part of eapmlib.

    Eapmlib is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or any 
	later version.

    Eapmlib is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __EVALUATOR_H__
#define __EVALUATOR_H__

#include "EvolutiveLib.h"
#include "Population.h"

namespace Evolutive {
	//! This class defines the base class for any evolutionary algorithm that uses this library.
	class EVOLUTIVELIB_API CEvaluator
	{
		//! Methods
	public:
		//! Default constructor		
		CEvaluator(void);
		
		//! Default destructor
		virtual ~CEvaluator(void);

		//! Returns the description of the problem. Number of variables and size in bits
		int* GetProblemDesc(int &NumVars);

		//! Returns the score for a given chromosome
		virtual double GetScore(CChromosome *C) = 0;

		//! Evalue the population
		void EvalPopulation(CPopulation *Population);

		//! Sets the problem description
		void SetProblemDesc(int NumVars,int* VarLenght);

		//! Set the ranges of all the variables
		void SetParameterRange(int NumVars,unsigned int *MinVals,unsigned int *MaxVals);

		//! Verify if a certain Chromosome is a valid solution
		virtual bool IsValid(CChromosome *C) = 0;
						
	protected:
							
		//! Attributes
	protected:
		//! Number of variables
		int m_NumFields;

		//! Number of bits used to codify each variable
		int *m_FieldsNumBits;		

		//! Min value for the parameters
		unsigned int *m_VarMinValue;

		//! Max value for the parameters
		unsigned int *m_VarMaxValue;
	};	
}

#endif // __EVALUATOR_H__
